﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using XMK.Tadong.Model;
using XMK.Framework.Model;
using XMK.Tadong.Data;
using XMK.Utils;

namespace XMK.Tadong.Biz
{
    public class V_Base_Struct_KeywBiz
    {
        /// <summary>
        /// 结构化数据检索
        /// </summary>
        /// <param name="keyw"></param>
        /// <param name="pageInfo"></param>
        /// <param name="order"></param>
        /// <returns></returns>
        public ResponseInfo QueryList(string keyw, PageInfo pageInfo, OrderInfo order)
        {
            ResponseInfo response = null;
            try
            {
                V_Base_Struct_KeywData data = new V_Base_Struct_KeywData(Config.TadongDbProvider);
                response = new ResponseInfo();
                response.Data = data.QueryList(keyw, pageInfo, order);
                response.Page = pageInfo;
            }
            catch (Exception ex)
            {
                //生成返回对象（带错误信息）
                response = new ResponseInfo("error！");
                LogHelper.WriteLog(LogType.Error, "[V_Base_Struct_KeywBiz.QueryList:]" + ex.ToString());
            }
            return response;
            
        }

        /// <summary>
        /// 结构化数据检索
        /// </summary>
        /// <param name="keyw"></param>
        /// <param name="pageInfo"></param>
        /// <param name="order"></param>
        /// <returns></returns>
        public ResponseInfo SearchList(string keyw)
        {
            ResponseInfo response = null;
            try
            {
                V_Base_Struct_KeywData data = new V_Base_Struct_KeywData(Config.TadongDbProvider);
                response = new ResponseInfo();
                response.Data = data.SearchList(keyw);
            }
            catch (Exception ex)
            {
                //生成返回对象（带错误信息）
                response = new ResponseInfo("error！");
                LogHelper.WriteLog(LogType.Error, "[V_Base_Struct_KeywBiz.SearchList:]" + ex.ToString());
            }
            return response;

        }

        /// <summary>
        /// 根据表名取列配置信息
        /// </summary>
        /// <param name="tableEngName"></param>
        /// <returns></returns>
        public ResponseInfo QueryTableColumnList(string tableEngName)
        {
            ResponseInfo response = null;
            try
            {
                V_Base_Struct_KeywData data = new V_Base_Struct_KeywData(Config.TadongDbProvider);
                response = new ResponseInfo();
                response.Data = data.QueryTableColumnList(tableEngName);
            }
            catch (Exception ex)
            {
                //生成返回对象（带错误信息）
                response = new ResponseInfo("error！");
                LogHelper.WriteLog(LogType.Error, "[V_Base_Struct_KeywBiz.QueryTableColumnList:]" + ex.ToString());
            }
            return response;

        }
        /// <summary>
        /// 根据表名取列配置信息
        /// </summary>
        /// <param name="tableEngName"></param>
        /// <returns></returns>
        public List<BaseTableColumnDictInfo> QueryTableColumnList1(string tableEngName)
        {
            
            try
            {
                V_Base_Struct_KeywData data = new V_Base_Struct_KeywData(Config.TadongDbProvider);
                return data.QueryTableColumnList(tableEngName);
            }
            catch (Exception ex)
            {
                //生成返回对象（带错误信息）
                LogHelper.WriteLog(LogType.Error, "[V_Base_Struct_KeywBiz.QueryTableColumnList:]" + ex.ToString());
            }
            return null;
        }

        public ResponseInfo QueryTableData(string tableEngName, string keyw, PageInfo page, OrderInfo orderInfo)
        {
            ResponseInfo response = null;
            try
            {
                V_Base_Struct_KeywData data = new V_Base_Struct_KeywData(Config.TadongDbProvider);
                response = new ResponseInfo();
                response.Data = data.QueryTableData(tableEngName,keyw, page, orderInfo);
                response.Page = page;
            }
            catch (Exception ex)
            {
                //生成返回对象（带错误信息）
                response = new ResponseInfo("error！");
                LogHelper.WriteLog(LogType.Error, "[V_Base_Struct_KeywBiz.QueryTableData:]" + ex.ToString());
            }
            return response;
        }
    }
}
